<?php
require_once('../model/addArt.php');
if ($_SERVER['REQUEST_METHOD'] == "POST") {
  if (isset($_POST['action']) && $_POST['action'] == 'uploadArt') {
    $artBoard = trim($_POST['artBoard']);
    $artTitle = trim($_POST['artTitle']);
    $text = trim($_POST['text']);
    $num = addArticle($artBoard, $artTitle, $text);

    $datetime = new DateTime('now', new DateTimeZone('Asia/Shanghai'));
    $nowTime = $datetime->format('Y-m-d H:i:s');
    if ($num > 0) {
      changeBoardTime($artBoard, $nowTime);
      echo "<script>alert('上传成功');window.location.href='../view/addArtIndex.php';</script>";
    } else {
      echo "<script>alert('上传失败');window.location.href='../view/addArtIndex.php';</script>";
    }
  }
}
?>